package com.controller;

import com.dao.ActivetypeDao;
import com.dto.DTO;
import com.entity.Activetype;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller //@Controller注解是用spring容器生成 对象 默认对象名 activetypeController
@RequestMapping("/activetypeController") //@RequestMapping 用户请求查找该资源使用的名字 网名 默认  /activetypeController
public class ActivetypeController {
	@Resource
    ActivetypeDao activetypeDao;
	@RequestMapping("/getAllActivetype")

	@ResponseBody //把方法的返回值按json转换之后 输出到浏览器
    public DTO<Activetype> getAllActivetype(){
    	System.out.println("查询全部社团");
    	List<Activetype> activetypes =  activetypeDao.getAllActivetypes();
    	return new DTO<Activetype>(200, "查询全部社团",activetypes);
    }

	@RequestMapping("/deleteActivetypeById/{aId}")
	@ResponseBody
    public DTO<Activetype> deleteActivetypeById(@PathVariable("aId") String aId){//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
    	System.out.println(aId+"删除社团");
    	return new DTO<Activetype>(200, "删除"+aId+"社团成功");
    }
}
